// interface Cat {
//   name: string
//   run(): void
// }
// interface Fish {
//   name: string
//   swim(): void
// }

// function getName(animal: Cat | Fish) {
//   return (animal as Fish).swim()
// }

// ;(window as any).foo = 1

// function getCacheData(key: string): any {
//   return (window as any).cache[key]
// }

// interface Cat {
//   name: string
//   run(): void
// }

// const tom = getCacheData('tom') as Cat
// tom.run()

class ApiError extends Error {
  code: number = 0
}
class HttpError extends Error {
  statusCode: number = 200
}

function isApiError(error: Error) {
  if (typeof (error as ApiError).code === 'number') {
    return true
  }
  return false
}
